package com.xinchao.service;

import com.xinchao.exception.ServiceException;
import com.xinchao.model.User;
import com.xinchao.model.page.PageInfo;
import com.xinchao.model.vo.UserListVO;

import javax.servlet.http.HttpServletRequest;

/**
 * 用户Service
 *
 * @author dxy
 * @date 2018/6/21 15:22
 */
public interface UserService {
	/**
	 * 保存用户
	 *
	 * @param user    User
	 * @param roleIds 角色IDS
	 * @param request HttpServletRequest
	 */
	void insertUser(User user, String roleIds, HttpServletRequest request) throws ServiceException;

	/**
	 * 修改用户
	 *
	 * @param user    User
	 * @param roleIds 角色IDS
	 * @param request HttpServletRequest
	 */
	void updateUser(User user, String roleIds, HttpServletRequest request);

	/**
	 * 通过用户名获取用户
	 *
	 * @param userName 用户名
	 * @return User(用户)
	 */
	User getUserByUserName(String userName);

	/**
	 * 获取用戶列表
	 *
	 * @param status       状态
	 * @param userName     用户名
	 * @param departmentId 部门ID
     * @param pageNum      当前页
     * @param pageSize     条数
     * @return PageInfo<UserListVO>
	 */
	PageInfo<UserListVO> listUser(Integer status, String userName, Long departmentId, Integer pageNum, Integer pageSize);


	/**
	 * 通过用户ID获取用户
	 *
	 * @param userId 用户ID
	 * @return User(用户)
	 */
	User getUserById(Long userId);

	/**
	 * 根据主键更新
	 * @param user
	 */
	void updateByPrimaryKey(User user);

	/**
	 * 通过姓名获取用户
	 *
	 * @param realName 姓名
	 * @return User(用户)
	 * @throws ServiceException
	 */
	User getUserByRealName(String realName) throws ServiceException;

	/**
	 * 修改密码
	 * @param userId   用户ID
	 * @param password 密码
	 * @throws ServiceException
	 */
	void updatePassword(Long userId, String password, HttpServletRequest request) throws ServiceException;

	/**
	 * 重置密码
	 *
	 * @param userId   用户ID
	 * @param password 密码
	 * @param request  HttpServletRequest
	 * @throws ServiceException
	 */
	void resetPassword(Long userId, String password, HttpServletRequest request) throws ServiceException;

	/**
	 * 启用禁用用户
	 * @param userId 用户ID
	 * @param status 状态
	 * @param request HttpServletRequest
	 */
	void enableDisableUser(Long userId, Integer status, HttpServletRequest request) throws ServiceException;

	/**
	 * 批量启用用户
	 * @param ids 用户id（多个英文逗号隔开）
	 * @param status 状态
	 * @param loginUser 登录用户
	 * @param ip 登录用户的ip
	 * @author linqiang
	 */
    void batchAbleDisable(String ids, Integer status, User loginUser, String ip) throws ServiceException;
}
